package com.lam.mall.service.impl;

import java.util.List;
import java.util.Objects;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import com.lam.common.utils.StringUtils;
import org.springframework.stereotype.Service;
import com.lam.mall.mapper.TransFeeCityMapper;
import com.lam.mall.entity.TransFeeCity;
import com.lam.mall.param.TransFeeCityParam;
import com.lam.mall.service.TransFeeCityService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;

/**
 * 运费城市Service业务层处理
 * 
 * @author admin
 * @date 2023-04-21
 */
@Service
public class TransFeeCityServiceImpl  implements TransFeeCityService {

    @Autowired
    private TransFeeCityMapper transFeeCityMapper;

    /**
     * 查询运费城市
     * 
     * @param id ID
     * @return 单个对象
     */
    @Override
    @Transactional(readOnly = true)
    public TransFeeCity selectById(String id) {

        return transFeeCityMapper.selectById(id);
    }

    /**
     * 查询运费城市列表
     * 
     * @param param
     * @return 
     */
    @Override
    @Transactional(readOnly = true)
    public List<TransFeeCity> selectList(TransFeeCityParam param) {
    
        QueryWrapper<TransFeeCity> queryWrapper = new QueryWrapper<>();
        
        queryWrapper.eq(Objects.nonNull(param.getTransFeeItemId()), "trans_fee_item_id", param.getTransFeeItemId());
        queryWrapper.eq(Objects.nonNull(param.getCityId()), "city_id", param.getCityId());

        return transFeeCityMapper.selectList(queryWrapper);
    }

    /**
     * 新增运费城市
     * 
     * @param transFeeCity 
     * @return 
     */
    @Override
    @Transactional
    public int insert(TransFeeCity transFeeCity) {
    
        return transFeeCityMapper.insert(transFeeCity);
    }

    /**
     * 修改运费城市
     * 
     * @param transFeeCity 
     * @return 
     */
    @Override
    @Transactional
    public int update(TransFeeCity transFeeCity) {
    
        return transFeeCityMapper.updateById(transFeeCity);
    }

    /**
     * 删除运费城市信息
     * 
     * @param idStr ID，多个用逗号分隔
     * @return 
     */
    @Override
    @Transactional
    public int deleteById(String idStr) {
    
        if(StringUtils.isBlank(idStr)) {
            return 0;
        }
        return transFeeCityMapper.deleteBatchIds(StringUtils.str2List(idStr));
    }
    
    
}
